Removed two function calls in common path
authorØyvind Kolås <pippin@gimp.org>
Tue, 24 Nov 2009 01:04:38 +0000 (01:04 +0000)
committerØyvind Kolås <pippin@gimp.org>
Tue, 24 Nov 2009 01:12:16 +0000 (01:12 +0000)
Re-arranged code making babl_process and babl_fish_process reside
in babl-path-fish.c, where babl_fish_process and babl_fish_path_process
can be inlined with babl_process().

babl/babl-fish-path.c
babl/babl-fish.c
babl/babl-internal.c
babl/babl-internal.h

index 10ce65d2699da6851fde7132608e641a9fa9c949..08667cf9128aa486fff644f970b942f4150ff6bb 100644 (file)
@@ -301,25 +301,99 @@ babl_fish_path (const Babl *source,
   return babl;
 }
 
-long
+static long
 babl_fish_path_process (Babl *babl,
                         void *source,
                         void *destination,
                         long  n)
 {
-  long ret;
-
-  babl_assert (source);
-  babl_assert (destination);
-
-  ret = process_conversion_path (babl->fish_path.conversion_list,
+  return process_conversion_path (babl->fish_path.conversion_list,
                                  source,
                                  destination,
                                  n);
 
+}
+
+
+static long
+babl_fish_process (Babl *babl,
+                   void *source,
+                   void *destination,
+                   long  n)
+{
+  long ret = 0;
+
+  switch (babl->class_type)
+    {
+      case BABL_FISH_REFERENCE:
+        if (babl->fish.source == babl->fish.destination)
+          { /* XXX: we're assuming linear buffers */
+            memcpy (destination, source, n * babl->fish.source->format.bytes_per_pixel);
+            ret = n;
+          }
+        else
+          {
+            ret = babl_fish_reference_process (babl, source, destination, n);
+          }
+        break;
+
+      case BABL_FISH_SIMPLE:
+        if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
+          {
+            ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
+                                           source, destination, n);
+          }
+        else
+          {
+            babl_fatal ("Cannot use a simple fish to process without a linear conversion");
+          }
+        break;
+
+      case BABL_FISH_PATH:
+        ret = babl_fish_path_process (babl, source, destination, n);
+        break;
+
+      default:
+        babl_log ("NYI");
+        ret = -1;
+        break;
+    }
+
   return ret;
 }
 
+long
+babl_process (Babl *babl,
+              void *source,
+              void *destination,
+              long  n)
+{
+  babl_assert (babl);
+  babl_assert (source);
+  babl_assert (destination);
+  babl_assert (BABL_IS_BABL (babl));
+  if (n == 0)
+    return 0;
+  babl_assert (n > 0);
+
+  /* first check if it is a fish since that is out fast path */
+  if (babl->class_type >= BABL_FISH ||
+      babl->class_type <= BABL_FISH_PATH)
+    {
+      babl->fish.processings++;
+      return babl->fish.pixels +=
+             babl_fish_process (babl, source, destination, n);
+    }
+
+  /* matches all conversion classes */
+  if (babl->class_type >= BABL_CONVERSION &&
+      babl->class_type <= BABL_CONVERSION_PLANAR)
+    return babl_conversion_process (babl, source, destination, n);
+
+  babl_fatal ("eek");
+  return -1;
+}
+
 static long
 process_conversion_path (BablList *path,
                          void     *source_buffer,
index d2cda12d583e515e41b789515184faf5c47ce0d2..a09efaf2975fec195fefea14c8ea73454d2db938 100644 (file)
@@ -278,53 +278,6 @@ babl_fish (const void *source,
   }
 }
 
-long
-babl_fish_process (Babl *babl,
-                   void *source,
-                   void *destination,
-                   long  n)
-{
-  long ret = 0;
-
-  switch (babl->class_type)
-    {
-      case BABL_FISH_REFERENCE:
-        if (babl->fish.source == babl->fish.destination)
-          { /* XXX: we're assuming linear buffers */
-            memcpy (destination, source, n * babl->fish.source->format.bytes_per_pixel);
-            ret = n;
-          }
-        else
-          {
-            ret = babl_fish_reference_process (babl, source, destination, n);
-          }
-        break;
-
-      case BABL_FISH_SIMPLE:
-        if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
-          {
-            ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
-                                           source, destination, n);
-          }
-        else
-          {
-            babl_fatal ("Cannot use a simple fish to process without a linear conversion");
-          }
-        break;
-
-      case BABL_FISH_PATH:
-        ret = babl_fish_path_process (babl, source, destination, n);
-        break;
-
-      default:
-        babl_log ("NYI");
-        ret = -1;
-        break;
-    }
-
-  return ret;
-}
-
 
 
 static int
index eac0a956e8e4f523bb1b156b8622c30275dba280..49a9010cdc4ca48b114225d38b8e46ed5bbfc1b1 100644 (file)
@@ -75,40 +75,6 @@ babl_die (void)
   exit (-1);
 }
 
-long
-babl_process (Babl *babl,
-              void *source,
-              void *destination,
-              long  n)
-{
-  babl_assert (babl);
-  babl_assert (source);
-  babl_assert (destination);
-  babl_assert (BABL_IS_BABL (babl));
-  if (n == 0)
-    return 0;
-  babl_assert (n > 0);
-
-  /* matches all conversion classes */
-  if (babl->class_type >= BABL_CONVERSION &&
-      babl->class_type <= BABL_CONVERSION_PLANAR)
-    return babl_conversion_process (babl, source, destination, n);
-
-  if (babl->class_type == BABL_FISH ||
-      babl->class_type == BABL_FISH_REFERENCE ||
-      babl->class_type == BABL_FISH_PATH ||
-      babl->class_type == BABL_FISH_SIMPLE)
-    {
-      long ret;
-      ret = babl_fish_process (babl, source, destination, n);
-      babl->fish.processings++;
-      babl->fish.pixels += ret;
-      return ret;
-    }
-
-  babl_fatal ("eek");
-  return -1;
-}
 
 BablMutex *babl_format_mutex;
 #if BABL_DEBUG_MEM
@@ -123,7 +89,6 @@ babl_internal_init (void)
   babl_format_mutex = babl_mutex_new ();
 #if BABL_DEBUG_MEM
   babl_debug_mutex = babl_mutex_new ();
-  fprintf (stderr, "%p %p\n", babl_debug_mutex, babl_format_mutex);
 #endif
 }
 
index 451c5f867bed821af62b66d2403affd78480e119..70538e92d2b1bd5e8ae4c831f0eb13596371203a 100644 (file)
@@ -81,10 +81,6 @@ void     babl_set_extender              (Babl           *new_extender);
 
 Babl   * babl_extension_quiet_log       (void);
 
-long     babl_fish_process              (Babl           *babl,
-                                         void           *source,
-                                         void           *destination,
-                                         long            n);
 long     babl_fish_reference_process    (Babl           *babl,
                                          BablImage      *source,
                                          BablImage      *destination,
@@ -98,10 +94,6 @@ void     babl_fish_stats                (FILE           *file);
 Babl   * babl_fish_path                 (const Babl     *source,
                                          const Babl     *destination);
 
-long     babl_fish_path_process         (Babl           *babl,
-                                         void           *source,
-                                         void           *destination,
-                                         long            n);
 int      babl_fish_get_id               (const Babl     *source,
                                          const Babl     *destination);